
<!DOCTYPE html>
<html lang="zh-CN">

<head>

        <meta charset="utf-8">
        <title>Login in</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- CSS -->
        <link rel="stylesheet" href='{{ url_for("static", filename="css/bootstrap.min.css") }}' >
        <link rel="stylesheet" href='{{ url_for("static", filename="css/login.css") }}' >

<style>

    #footer{
    clear: both;
    display: block;
    text-align: center;
    margin: 0px auto;
    position: absolute;
    bottom: 0px;
    width: 100%;
}

</style>
</head>
<body>
    <div class="container">
            <div class="row">
                <div class="col-md-offset-3 col-md-6">

                  <form class="form-horizontal" id="login-form" data="{{url_for('auth.login', next=request.args.get('next','/'))}}" >
                    <div>

                      <h3 class="heading"><img src='{{url_for("static",filename="picture/Team.png")}}' style="width:10%;" />NetVisionX</h3>
                    </div>
                        <span class="heading">用户登录</span>
                        <div class="form-group">
                            <input type="text" class="form-control" name="username" id="username" placeholder="用户名或电子邮件">
                            <i class="fa fa-user"></i>
                        </div>
                        <div class="form-group help">
                            <input type="password" class="form-control" name="password" id="passwd" placeholder="密　码">
                            <i class="fa fa-lock"></i>
                            <a href="#" class="fa fa-question-circle"></a>
                        </div>
                        <div class="form-group">
                        <!--
                            <div class="main-checkbox">
                                <input type="checkbox" value="None" id="checkbox1" name="check"/>
                                <label for="checkbox1"></label>
                            </div>
                            <span class="text">Remember me</span>
                        -->
                            <button id="login" type="button" class="btn btn-default">登录</button>
                        </div>
                    </form>
                </div>
            </div>
    </div>
</body>

<script type=text/javascript src="{{ url_for('static', filename='js/jquery-3.2.1.min.js') }}"></script>
<script type="text/javascript">
$(document).ready(function(){
  $('#login').click(function(event){
    $.ajax({
      url: $('#login-form').attr("data"),
      data:{
        'username': $('#username').val(),
        'passwd': $('#passwd').val(),
      },
      dataType: 'JSON',
      type: 'POST',
      success: function(data){
        console.log(data);
        if(data.login===1){
          location.href=data.next
        }else{
          alert("Password Wrong");
        }
      }
    });
  });
  $(document).keydown(function(event){
    if(event.keyCode===13){
        $("#login").click();
    }
  });
});
</script>

</html>
